func (m *default{{.upperStartCamelObject}}Inter) Update(ctx context.Context, {{if .containsIndexCache}}newData{{else}}data{{end}} *{{.upperStartCamelObject}}) error {
	{{if .withCache}}{{if .containsIndexCache}}data, err:=m.FindOne(ctx, newData.{{.upperStartCamelPrimaryKey}})
	if err!=nil{
		return err
	}

{{end}}	{{.keys}}
    _, {{if .containsIndexCache}}err{{else}}err:{{end}}= m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
		query := fmt.Sprintf("update %s set %s where {{.originalPrimaryKey}} = {{if .postgreSql}}$1{{else}}?{{end}}", m.table, {{.lowerStartCamelObject}}RowsWithPlaceHolder)
		return conn.ExecCtx(ctx, query, {{.expressionValues}})
	}, {{.keyValues}}){{else}}query := fmt.Sprintf("update %s set %s where {{.originalPrimaryKey}} = {{if .postgreSql}}$1{{else}}?{{end}}", m.table, {{.lowerStartCamelObject}}RowsWithPlaceHolder)
    _,err:=m.conn.ExecCtx(ctx, query, {{.expressionValues}}){{end}}
	return err
}

func (m *default{{.upperStartCamelObject}}Inter) UpdateWithVersion(ctx context.Context, session sqlx.Session, {{if .containsIndexCache}}newData{{else}}data{{end}} *{{.upperStartCamelObject}}) (int64, error) {

	 {{if .containsIndexCache}}
         oldVersion := newData.Version
         newData.Version += 1
        {{else}}
        oldVersion := data.Version
        data.Version += 1
        {{end}}

    	var sqlResult sql.Result
    	var err error

    	{{if .withCache}}{{if .containsIndexCache}}data, err:=m.FindOne(ctx, newData.{{.upperStartCamelPrimaryKey}})
                if err!=nil{
                    return err
                }
        {{end}}{{.keys}}
    	sqlResult,err =  m.ExecCtx(ctx,func(ctx context.Context,conn sqlx.SqlConn) (result sql.Result, err error) {
    	query := fmt.Sprintf("update %s set %s where {{.originalPrimaryKey}} = {{if .postgreSql}}$1{{else}}?{{end}} and version = ? ", m.table, {{.lowerStartCamelObject}}RowsWithPlaceHolder)
    	if session != nil{
    		return session.ExecCtx(ctx,query, {{.expressionValues}},oldVersion)
    	}
    	return conn.ExecCtx(ctx,query, {{.expressionValues}},oldVersion)
    	}, {{.keyValues}}){{else}}query := fmt.Sprintf("update %s set %s where {{.originalPrimaryKey}} = {{if .postgreSql}}$1{{else}}?{{end}} and version = ? ", m.table, {{.lowerStartCamelObject}}RowsWithPlaceHolder)
    	if session != nil{
    		sqlResult,err  =  session.ExecCtx(ctx,query, {{.expressionValues}},oldVersion)
    	}else{
    		sqlResult,err  =  m.conn.ExecCtx(ctx,query, {{.expressionValues}},oldVersion)
    	}
    	{{end}}
    	if err != nil {
    		return 0,err
    	}
    	affected , err := sqlResult.RowsAffected()
    	if err != nil{
    		return affected,err
    	}
    	if affected == 0 {
    		return affected,NotModified
    	}
    	return affected,nil
}